package com.oocl.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.oocl.dao.GoodsDao;
import com.oocl.dao.WareHouseDao;
import com.oocl.dao.impl.GoodsDaoImpl;
import com.oocl.dao.impl.WareHouseDaoImpl;
import com.oocl.pojo.Goods;
import com.oocl.pojo.Warehouse;

/**
 * Servlet implementation class ViewWareHouse
 */
public class ViewWareHouse extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private WareHouseDao wareHouseDao;
	private GoodsDao goodsDao;
    public ViewWareHouse() {
        super();
        goodsDao = new GoodsDaoImpl();
        wareHouseDao = new WareHouseDaoImpl();
    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession sen = request.getSession();
		int uid = (int)sen.getAttribute("uid");
		
		List<Goods> list = goodsDao.getGoodsFromWareHouse(uid);
		
		List<Warehouse> wareHouseList = wareHouseDao.loadWareHouse();
		System.out.println(uid + " in view ");
		sen.setAttribute("uid",uid);
		sen.setAttribute("wareHouseList", wareHouseList);
		sen.setAttribute("list", list);
		
		request.getRequestDispatcher("../display.jsp").forward(request, response);
	}

}
